import { TriggerColorStrMap, TriggerStrMap, TriggerTypeLogoMap, UaCard } from "../../models/ua-card.model";
import { GlobalService } from "../../services/global.service";

// components/deck-card-detail/deck-card-detail.component.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    isAp: {
      type: Boolean,
      value: false,
    },
    card: {
      type: Object,
      value: {}
    },
  },

  observers: {
    'card': function () {
      this.setData({ uaCard: this.data.card, hasStar: this.data.card.rare?.includes('★') || this.data.card.packNo?.includes('PR') || this.data.card.packNo?.includes('PC') || this.data.card.rare?.includes('SR') || this.data.card.rare?.includes('SP') });
    },
    'isAp': function () {
      this.setData({ ap: this.data.isAp });
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    FILE_HOST: GlobalService.FILE_HOST,
    STATIC_ASSETS_HOST: GlobalService.STATIC_ASSETS_HOST,
    imgOnly: false,
    ap: false,
    uaCard: {} as UaCard,
    TriggerTypeLogoMap: TriggerTypeLogoMap,
    TriggerStrMap: TriggerStrMap,
    TriggerColorStrMap: TriggerColorStrMap,
    hasStar: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onNext: function () {
      this.triggerEvent('next', this.data.uaCard.id)
    },
    onPrev: function () {
      this.triggerEvent('prev', this.data.uaCard.id)
    },
    showImgOnly: function () {
      this.setData({ imgOnly: !this.data.imgOnly });
      GlobalService.DISPLAY['imgOnly'] = this.data.imgOnly;
    },
    qa: function () {
      wx.navigateTo({
        url: `/pages/user/card-detail/card-detail.page?cardId=${this.data.uaCard.id}`,
      });
    },
  }
})